﻿namespace ``Concerning the assertion syntax``

open FSpec
open System.Linq
open System.Collections.Generic 

module ``Types``=

    let ``it provide inheritance assertions``()=
        ["";""] |> should.inheritFrom typeof<IEnumerable<string>>

    let ``it provide an instance assertion``()=
        ["";""] |> should.beA typeof<string list>

    let ``it fail should.beA``()=
        capture(fun()->
            ["";""] |> should.beA typeof<IEnumerable<string>>
        )

    let ``it fail shouldNot.beA``()=
        capture(fun()->
            ["";""] |> shouldNot.beA typeof<string list>
        )

    let ``it provide a null reference check``()=
        null |> should.beNull

    let ``it fail a null reference check``()=
        capture(fun()->
            "mwahahaha" |> should.beNull
        )

    let ``it fail a not null check``()=
        capture(fun()->
            let a = null
            a |> shouldNot.beNull
        )

    let ``it fail should.inheritFrom``()=
        capture(fun()->

            string |> should.inheritFrom typeof<int>

        ).Description 
        |> should.equal (format 
                            Resources.TheObjectShouldInheritFromType_0_ 
                            [typeof<int>])
  
    let ``it fail shouldNot.inheritFrom``()=
        capture(fun()->

            ["";""] |> shouldNot.inheritFrom typeof<IEnumerable<string>>
        
        ).Description
        |> should.equal (format
                            Resources.TheObjectShouldNotInheritFromType_0_ 
                            [typeof<IEnumerable<string>>])


